package com.gao.objectfactory;

import org.apache.ibatis.reflection.factory.DefaultObjectFactory;

import java.util.*;

/**
 * 自定义对象工厂
 *
 * @author gaoxi
 */
public class ExampleObjectFactory extends DefaultObjectFactory {

    /**
     * 使用无参方式创建工厂
     *
     * @param type
     * @return
     */
    @Override
    public Object create(Class type) {
        return super.create(type);
    }


    @Override
    public <T> T create(Class<T> type, List<Class<?>> constructorArgTypes, List<Object> constructorArgs) {
        return super.create(type, constructorArgTypes, constructorArgs);
    }

    /**
     * 读取配置自定义工厂中定义的 属性
     *
     * @param properties
     */
    @Override
    public void setProperties(Properties properties) {
        System.out.println(properties.get("hello"));
        super.setProperties(properties);
    }

    @Override
    public <T> boolean isCollection(Class<T> type) {
        return Collection.class.isAssignableFrom(type);
    }
}